<?php

namespace App\Admin\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Support\Facades\DB;

class Ordery extends Authenticatable
{
    use Notifiable;

    protected $table = 'shop_orders';

    public function getStatusTextAttribute(){
        $array = [
            '-1' => '取消',
            '0' => '已下单',
            '1' => '待激活',
            '2' => '已完成',
        ];
        return $array[$this->status];
    }
    public function getSourceTextAttribute(){
        $array = [
            '1' => '公众号',
            '2' => '天猫',
            '3' => '京东',
            '4' => '拼多多',
        ];
        return $array[$this->source];
    }
    public function getGoodsIdTextAttribute(){
        return DB::table('shop_goods')->where('id',$this->goods_id)->value('name');
    }
    public function getAgentTextAttribute(){
        return DB::table('users')->where('id',$this->agent)->value('realname');
    }
    public function getUidTextAttribute(){
        return DB::table('users')->where('id',$this->uid)->value('realname');
    }
}
